package d3_tranfers_stream;

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.InputStreamReader;

public class InputStreamReaderDemo01 {
    public static void main(String[] args) {
        //目标: 字符输入转换流

        try (
                //这里知只能放置资源对象, 用完之后自动调用资源的close方法关闭资源
                //1、創建一个字节输入流 --》得到GBK文件的原始字节输入流
                InputStream is = new FileInputStream("javapromax\\day10-io-code\\src\\陈某GBK.txt");
                //2、通过字符输入转换流把原始字节流按照指定的规则转换成字符输入流
                InputStreamReader isr = new InputStreamReader(is, "GBK");
                //3、把字符输入流包装成高级的缓冲字符输入流
                BufferedReader br = new BufferedReader(isr)
        ) {

            //4、按照行进行读取
            String line;
            while((line = br.readLine()) != null){
                System.out.println(line);
            }

        } catch (Exception e) {
            //打印堆栈信息
            e.printStackTrace();
        }
    }
}
